package com.le.tester.book.effectivejava3rdchinese.secondReading.l42;

import java.util.function.DoubleBinaryOperator;

/**
 * createTime：2024-09-25 9:23
 * description：使用lambda使得代码更加的简洁
 */
public enum Operation {
    PLUS("+", Double::sum);

    public final String symbol;

    public final DoubleBinaryOperator op;

    Operation(String symbol, DoubleBinaryOperator op) {
        this.symbol = symbol;
        this.op = op;
    }

    public double apply(double x, double y) {
        return op.applyAsDouble(x, y);
    }

}
